<!DOCTYPE html>
<html>
<head>
  {include file="common/meta" /}
  {include file="common/link" /}
<style>
body { background-color: #fff!important; }
</style>
</head>
<body class="body-1">
<div id="container"> 
  <!--购物车为空-->
    <div>
      <div id="footer" class=" mui-bar-tab cart-btn-box centerflex line-top" style="background-color: #333333;bottom: 50px;">
<!--        <label><input type="checkbox" value="1" class="checkall">全选</label>-->
        <div class="total-price box-flex-1">

        </div>
        <a class="qujiesuan">生成采购单</a> <span class="del-car" style="display: none;">删除</span>
      </div>


    <div class="">
      <div class="home-link-box bgcolor-white clearfix"><a href="javascript:void(0)" class="fl">
        <i class="iconfont icon-shop"></i></a>
        <div class="car-add fr"><span>新增</span></div>
      </div>
      <div id="car-list" class="car-list">
        <ul class="showdata">
            <!--  -->
          {volist name="list" id="vo"}
              <div class="weui-cell weui-cell_swiped catid{$vo.id}">
                <div class="weui-cell__bd" style="transform: translate3d(0px, 0px, 0px);">
                  <li class="display-box-middle weui-cell">
                    <label>
                      {if condition="$vo.ystatus == 1 "}
                          <input type="checkbox" value="{$vo.id}"  class="checklist" >
                      {else /}
                      <div type="" class="checklist">
                      </div>
                      {/if}

                    </label>

                    <div class="car-list-txt box-flex-1  ">
                      <a href="###" class="link">
                        <h2>{$vo.title}</h2>
<!--                        <p class="d-specs">规格: {$vo.specs}</p>-->
                        <p class="clearfix">
                          <span class="attribute fl"><em>规格：{$vo.specs}</em></span>
                          <span class="num fr">×<em class="ft14">{$vo.goods_num}</em></span>
                        </p>
                        <p>
                          <span class="line-top">仓库: {$vo.name}</span>
                          <span class="line-top" style=" color:red; ">{$vo.status}</span>

                        </p>
                      </a>
                    </div>
                  </li>
                </div>

                {if condition="$vo.ystatus == 1 "}
                <div class="weui-cell__ft">
                  <a class="weui-swiped-btn weui-swiped-btn_warn delete-swipeout" href="javascript:" style="display: flex;align-items: center;justify-content: center;" data-id="{$vo.id}"> 删除</a>
                </div>
                {else /}
                {/if}

              </div>
          {/volist}
<!--          <div class="weui-cell weui-cell_swiped" style="height: 50px">-->
<!--            <div class="weui-cell__bd" style="transform: translate3d(0px, 0px, 0px);">-->
<!--              <li class="display-box-middle weui-cell">-->

<!--              </li>-->
<!--            </div>-->

<!--          </div>-->
        </ul>
      </div>
    </div>
  </div>
  <!--左侧扇形导航-->
  <!--左侧扇形导航-->
</div>
{include file="common/footer" /}
{include file="common/script" /}

</body>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
</html>
<script>
  $('.car-add').click(function () {
      window.location.href = '/web/purchase/choose'
  })


















  page = 1
  pagesize = 10
  status = 0;
  var loading = false;  //状态标记
  var total = "{$total}"
  if(total<pagesize){
    loading = true;
    // $('.weui-loadmore__tips').html('暂无数据')
    $('.weui-loadmore').hide()
  }
  $(document.body).infinite().on("infinite", function() {
    if (loading) return;
    loading = true;
    var total = "{$total}"
    console.log('总数量:'+total)
    if (total < pagesize) {
      loading = true;
      // $('.weui-loadmore__tips').html('暂无数据')
      $('.weui-loadmore').hide()
      return false;
    }
    ajax()
  })
  function ajax(type = 0) {
    var url = "{$turl}"+'/web/purchase/getpurchase'
    $.post(url,{page:page,pagesize:pagesize,status:status},function (res) {
      loading = false;
      if(res.data.length >0){
        page++;
        var str = '';
        for (var i=0;i<res.data.length;i++){
          str+=' <div class="weui-cell weui-cell_swiped catid'+res.data[i]['id']+'">\n' +
                  '                <div class="weui-cell__bd" style="transform: translate3d(0px, 0px, 0px);">\n' +
                  '                  <li class="display-box-middle weui-cell">\n' +
                  '                    <label>\n' ;
                  if(res.data[i]['ystatus'] == 1){
                    str += '                          <input type="checkbox" value="'+res.data[i]['id']+'"  class="checklist" >\n' ;
                  }
                  str +='\n' +
                  '                    </label>\n' +
                  '                    <div class="car-list-txt box-flex-1  ">\n' +
                  '                      <a href="###" class="link">\n' +
                  '                        <h2>'+res.data[i]['title']+'</h2>\n' +
                  '                        <p class="clearfix">\n' +
                  '                          <span class="attribute fl"><em>规格：'+res.data[i]['specs']+'</em></span>\n' +
                  '                          <span class="num fr">×<em class="ft14">'+res.data[i]['goods_num']+'</em></span>\n' +
                  '                        </p>\n' +
                  '                        <p>\n' +
                  '                          <span class="line-top">仓库: '+res.data[i]['name']+'</span>\n' +
                  '                          <span class="line-top" style=" color:red; ">'+res.data[i]['status']+'</span>\n' +
                  '                        </p>\n' +
                  '                      </a>\n' +
                  '                    </div>\n' +
                  '                  </li>\n' +
                  '                </div>\n' ;
                   if(res.data[i]['ystatus'] == 1){
                     str += '                <div class="weui-cell__ft">\n' +
                             '                  <a class="weui-swiped-btn weui-swiped-btn_warn delete-swipeout" href="javascript:" style="display: flex;align-items: center;justify-content: center;" data-id="'+res.data[i]['id']+'"> 删除</a>\n' +
                             '                </div>\n';
                   }
                  str +='\n' +
                  '              </div>'
        }
        // if(type == 1 && res.data.length <pagesize){
        $('.weui-loading').hide()
        $('.weui-loadmore__tips').hide()
        // }
        $('.showdata').append(str)
      }else{
          loading = true;
          $('.weui-loadmore__tips').html('已经到底了')
          $('.weui-loading').hide()

        // $('.weui-loadmore_line').attr('style','display:block')
      }
    })
  }




  $('.weui-cell_swiped').swipeout()
  $('.delete-swipeout').on('click',function () {
    console.log($(this).data('id'))
    var url = "{$turl}"+'/web/purchase/del'
    $.post(url,{cart_id:$(this).data('id')},function (res) {
      layer.msg(res.msg)
      if(res.code>0){
        $('.catid'+res.data).remove()
      }
    })
  })

  $('.qujiesuan').click(function () {
    is_true = 0;
    ids = new Array();
    $('.weui-cell_swiped').each(function () {
      if($(this).find('.checklist').prop("checked") == true){
        is_true =1;
        ids.push($(this).find('.checklist').val())
      }
    })
    if(is_true == 0){
      layer.msg('您尚未选择任何商品')
    }else{
      var url = "{$turl}"+'/web/supplier/choose?ids='+ids.join("-");
      window.location.href = url
    }

  })

</script>
<!---带扇形 不带footer->
